import React from 'react';
import { format } from '@/utils/datetime';
import CommonPage from '@/components/page/CommonPage';
import { useModel } from 'umi';
import { renderNumber } from '@/utils/common';
const daoName = 'ShIndiShzsdr';
const importName = 'ShIndiShzsdr';
const columns: API.Column[] = [
  {
    title: '操作人',
    width: 120,
    sorter: true,
    dataIndex: 'CZR',
    key: 'CZR',
    dispaly: true,
    filter: false,
    export: false,
  },
  {
    title: '操作日期',
    width: 120,
    sorter: true,
    key: 'CZRQ',
    dataIndex: 'CZRQ',
    render: (data) => format(data, 'yyyy-MM-dd'),
    dispaly: true,
    filter: false,
    export: false,
  },
  {
    title: '交易日期',
    width: 120,
    sorter: true,
    key: 'JYRQ',
    dataIndex: 'JYRQ',
    render: (data) => format(data, 'yyyy-MM-dd'),
    dispaly: true,
    filter: true,
    export: false,
  },
  {
    title: '客户名称',
    width: 120,
    sorter: true,
    dataIndex: 'CUNM',
    key: 'CUNM',
    dispaly: true,
    filter: true,
    export: false,
  },
  {
    title: '证件号码',
    width: 200,
    sorter: true,
    dataIndex: 'IDNO',
    key: 'IDNO',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '产品名称',
    width: 200,
    sorter: true,
    dataIndex: 'CPNM',
    key: 'CPNM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '金额',
    width: 150,
    sorter: true,
    dataIndex: 'JE',
    key: 'JE',
    dispaly: true,
    filter: true,
    export: true,
    align: 'right',
    render: (data) => renderNumber('.2f', data),
  },
  {
    title: '产生中收',
    width: 150,
    sorter: true,
    dataIndex: 'CSZS',
    key: 'CSZS',
    dispaly: true,
    filter: true,
    export: true,
    align: 'right',
    render: (data) => renderNumber('.2f', data),
  },
  {
    title: '分配中收',
    width: 150,
    sorter: true,
    dataIndex: 'FPZS',
    key: 'FPZS',
    dispaly: true,
    filter: true,
    export: true,
    align: 'right',
    render: (data) => renderNumber('.2f', data),
  },
  {
    title: '员工名',
    width: 120,
    sorter: true,
    dataIndex: 'EMNM',
    key: 'EMNM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '部门',
    width: 250,
    sorter: true,
    dataIndex: 'PDNM',
    key: 'PDNM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '工号',
    width: 120,
    sorter: true,
    dataIndex: 'EMNO',
    key: 'EMNO',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '业绩统计日期',
    width: 150,
    sorter: true,
    key: 'DRRQ',
    dataIndex: 'DRRQ',
    render: (data) => format(data, 'yyyy-MM-dd'),
    dispaly: true,
    filter: true,
    export: false,
  },
];
const controls: API.Control[] = [
  { name: 'JYRQ', dataType: 'date', type: 'date', label: '交易日期', grid: 12 / 24 },
  { name: 'CUNM', type: 'text', label: '客户名称', grid: 12 / 24 },
  { name: 'IDNO', type: 'text', label: '证件号码', grid: 12 / 24 },
  { name: 'CPNM', type: 'text', label: '产品名称', grid: 12 / 24 },
  {
    name: 'JE',
    label: '金额',
    rules: [{ required: false, message: '不能为空' }],
    type: 'number',
    dataType: 'number',
    grid: 12 / 24,
  },
  {
    name: 'CSZS',
    label: '产生中收',
    rules: [{ required: false, message: '不能为空' }],
    type: 'number',
    dataType: 'number',
    grid: 12 / 24,
  },
  {
    name: 'FPZS',
    label: '分配中收',
    rules: [{ required: false, message: '不能为空' }],
    type: 'number',
    dataType: 'number',
    grid: 12 / 24,
  },
  { name: 'EMNM', type: 'text', label: '员工名', grid: 12 / 24 },
  { name: 'PDNM', type: 'text', label: '部门', grid: 12 / 24 },
  { name: 'EMNO', type: 'text', label: '工号', grid: 12 / 24 },
  { name: 'DRRQ', dataType: 'date', type: 'date', label: '业绩统计日期', grid: 12 / 24 },
];
const ShIndiShzsdrForm: React.FC = () => {
  const { user } = useModel('@@initialState', (ret) => {
    return {
      user: ret.initialState?.user,
    };
  });
  return (
    <CommonPage
      daoName={daoName}
      columns={columns}
      controls={controls}
      title="私行中收"
      importName={importName}
      importControls={controls}
      keyColName={'JLID'}
      importMode="DeleteAfterInsert"
      importParamNames={['DRRQ']}
      importParamVals={{ CZRID: '' + user?.userID, CZR: user?.name }}
      importTemplateName="私行中收导入模板"
      initSorter={{ FieldName: 'CZRQ', Direction: 'DESC' }}
    />
  );
};

export default ShIndiShzsdrForm;
